package main

import "fmt"

/**
函数的多种声明方式
*/
func main() {

	f := foo1("45", "88")

	fmt.Println("f=", f)

	fmt.Println("================")

	ret1, ret2 := foo2("abc", "def")

	fmt.Println("ret1=", ret1, "ret2=", ret2)

	fmt.Println("================")

	ret6, ret7 := foo3("abc", "def")

	fmt.Println("ret6=", ret6, "ret7=", ret7)

	ret8, ret9 := foo4("88jjj", 55)

	fmt.Println("ret8=", ret8, "ret9=", ret9)

}

func foo1(a string, b string) int {
	fmt.Println("====foo1===")
	fmt.Println("a=", a)
	fmt.Println("b=", b)
	c := 100
	return c
}

// 返回多个返回值 匿名的
func foo2(a string, b string) (int, int) {
	fmt.Println("====foo2===")
	fmt.Println("a=", a)
	fmt.Println("b=", b)
	return 666, 777

}

// 返回多个返回值 有形参名的
func foo3(a string, b string) (s1 int, s2 string) {
	fmt.Println("====foo3===")
	fmt.Println("s1,s2 的作用域是foo3函数的作用域   默认值数值类型为0 字符串默认值为空")
	fmt.Println("s1=", s1, "s2=", s2)
	fmt.Println("===a=", a)
	fmt.Println("===b=", b)
	// 给有名称的返回值变量赋值
	s1 = 1000
	s2 = "hello world"
	return
}

func foo4(a string, b int) (r1, r2 int) {
	fmt.Println("====foo4===")

	fmt.Println("a = ", a)
	fmt.Println("b = ", b)

	r1, r2 = 100, 200
	return

}
